﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Infrastucture;
using TimeSplicerModule.DomainModels;

namespace TimeSplicerModule.ViewModels
{
    public class CategoryViewModel : CategoryModel
    {
        private bool _isTaskSubCategory;
        private Guid _selectedTeamGuid;
        private Visibility _isGlobalVisiblity;
        private Visibility _parentCategoriesVisibility;
        private TeamModel _selectedTeam;
        private List<TeamModel> _teams;

        public new bool IsTaskSubCategory
        {
            get { return _isTaskSubCategory; }
            set
            {
                SetProperty(ref _isTaskSubCategory, value);
                this.ParentCategoriesVisibility = this.IsTaskSubCategory ? Visibility.Visible : Visibility.Collapsed;
            }
        }
        public Guid SelectedTeamGuid
        {
            get { return _selectedTeamGuid; }
            set 
            { 
                SetProperty(ref _selectedTeamGuid, value);

                if (this.Teams != null)
                {
                    this.SelectedTeam = this.Teams.FirstOrDefault(x => x.TeamGuid == this.SelectedTeamGuid);
                }
            }
        }
        public Visibility IsGlobalVisibility
        {
            get { return _isGlobalVisiblity; }
            set { SetProperty(ref _isGlobalVisiblity, value); }
        }
        public Visibility ParentCategoriesVisibility
        {
            get { return _parentCategoriesVisibility; }
            set { SetProperty(ref _parentCategoriesVisibility, value); }
        }
        public TeamModel SelectedTeam
        {
            get { return _selectedTeam; }
            set { SetProperty(ref _selectedTeam, value); }
        }
        public List<TeamModel> Teams
        {
            get { return _teams; }
            set { SetProperty(ref _teams, value); }
        }
    }

    public class CategoryListViewModel : ViewModel
    {
        private List<CategoryModel> _categories;
        
        public List<CategoryModel> Categories
        {
            get { return _categories; }
            set { SetProperty(ref _categories, value); }
        }
    }
}
